<script type="text/javascript" src="{{$LAYOUT_HELPER_URL}}admin/js/ckfinder/ckfinder.js"></script>
<script type="text/javascript">
	function chooseImage()
	{
	    // You can use the "CKFinder" class to render CKFinder in a page:
	    var finder = new CKFinder();
	    finder.basePath = '{{$LAYOUT_HELPER_URL}}admin/js/ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
	    finder.selectActionFunction = SetFileField;
	    finder.popup();
	
	    // It can also be done in a single line, calling the "static"
	    // Popup( basePath, width, height, selectFunction ) function:
	    // CKFinder.Popup( '../../', null, null, SetFileField ) ;
	    //
	    // The "Popup" function can also accept an object as the only argument.
	    // CKFinder.Popup( { BasePath : '../../', selectActionFunction : SetFileField } ) ;
	} 
	// This is a sample function which is called when a file is selected in CKFinder.
	function SetFileField( fileUrl )
	{
	    document.getElementById( 'chooseImage_img' ).src = fileUrl;
	    document.getElementById( 'chooseImage_input' ).value = fileUrl;
	    document.getElementById( 'chooseImage_div').style.display = '';
	    document.getElementById( 'chooseImage_noImage_div' ).style.display = 'none';
	}
	function clearImage()
	{
	    document.getElementById( 'chooseImage_img').src = '';
	    document.getElementById( 'chooseImage_input' ).value = '';
	    document.getElementById( 'chooseImage_div' ).style.display = 'none';
	    document.getElementById( 'chooseImage_noImage_div').style.display = '';
	}
</script>
       
            <div class="content-box"><!-- Start Content Box -->
                
                <div class="content-box-header">
                    <h3>New Ads</h3>
                    <div class="clear"></div>
                </div> <!-- End .content-box-header -->
                
                <div class="content-box-content">
                
                    <form action="" method="post">
                    
                    <div class="tab-content {{if !$fullPermisison}}hidden{{/if}}" id="tab0">
                    
                        <!-- ERROR -->
                        {{if $errors|@count > 0}}
                        <div class="notification error png_bg">
                            <a href="#" class="close"><img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
                            <div>
                                {{if $errors.main}}
                                    Error: {{$errors.main}}
                                {{else}}
                                    Error: Please check following information again
                                {{/if}} 
                                                                       
                            </div>
                        </div>
                        {{/if}}
                            
                            <fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
                                <p>
                                    <label>Ads name</label>
                                    <input class="text-input small-input" type="text" id="small-input" name="data[name]" value="{{$data.name}}" />              
                                </p>
                                 <p> <label>Ads Category</label>
                                	<select name="data[ads_category_id]" class="small-input">
	                                    {{foreach from=$allAdsCats item=item}}
	                                        <option value="{{$item.ads_category_id}}" {{if $data.ads_category_id == $item.ads_category_id}}selected="selected"{{/if}}>{{$item.name}}</option>
	                                    {{/foreach}}
                                    </select> 
                                </p>
                                <p><label>Sorting</label>
                                   <input class="text-input small-input" type="text" id="small-input" name="data[sorting]" value="{{$data.sorting}}" />
                                   <br /><small>No 1 will display as first ads</small>
                                </p>
                                
                                <!-- IMAGE -->
                               
                                <label class="w155">Image:</label>
                                    <div style="float: left; margin-top: 10px;" id ="image_div">
                                    
                                            <input type="hidden" id="chooseImage_input" name="data[image]" value="{{$BASE_URL}}{{$data.image}}">
                                            <div id="chooseImage_div" style="{{if !$data.image}} display:none{{/if}}">
                                                <img src="{{$BASE_URL}}{{$data.image}}" id="chooseImage_img" style="max-width: 150px; border:dashed thin;"></img><br/>
                                            </div>
                                            <div id="chooseImage_noImage_div" style="width: 150px; border: thin dashed; text-align: center; padding:70px 0px; {{if $data.image}} display:none{{/if}} ">
                                                No image
                                            </div>
                                            <br/>
                                            <a href="javascript:chooseImage();">Select Image</a>
                                            |
                                            <a href="javascript:clearImage();">Clear Image</a>
                                    </div>     
                                    <br style="clear: both;"/>  
                                    <br/> 
                                <!-- END IMAGE -->    
                                
                                <p>
                                    <label>URL</label>
                                        <input class="text-input small-input" type="text" id="small-input" name="data[url]" value="{{$data.url}}" />
                                </p>
                               
								<p>
                                    <label>Description</label>
                                    <textarea name="data[description]" rows="10" cols="50">{{$data.description}}</textarea>
                                </p>
                                
                                 <p>
                                    <label>Enabled</label>
                                    <input type="radio" name="data[enabled]" value="1" {{if $data.enabled != '0'}}checked="checked"{{/if}}/> Yes &nbsp;&nbsp;&nbsp;&nbsp;
                                    <input type="radio" name="data[enabled]" value="0" {{if $data.enabled == '0'}}checked="checked"{{/if}}/> No
                                </p>
                                                                
                                <p>
                                <br/>
                                    <input class="button" type="submit" value="Save" />
                                </p>
                                
                            </fieldset>
                            
                            <div class="clear"></div><!-- End .clear -->
                            
                    </div>
                    
                    
                  </form>
                  
                </div> <!-- End .content-box-content -->
                
            </div> <!-- End .content-box -->
            
            
            <div class="clear"></div>

<style type="text/css">
.cke_top {
	background-color: #dddddd;
}
</style>
